package com.witdata.controller.ping;

import com.witdata.common.service.UserService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/test")
@RequiredArgsConstructor
public class TestController {
    private final UserService userService;

    @GetMapping("/pool")
    public String pool(@RequestParam("count") int count, @RequestParam("thread") int thread) {
        for (int i = 0; i < thread; i++) {
            new Thread(() -> {
                for (int j = 0; j < count; j++) {
                    userService.getUserListBySleep();
                }
            }).start();
        }
        return "pool";
    }

}
